package com.jxb.test20241216;

import java.util.Arrays;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/12/23 1:12
 **/
public class Sort3 {

    public static void main(String[] args) {
        int[] nums = {1,4,3,6,0,4,5,9,4,2,6};
        System.out.println("排序开始----------------->" + Arrays.toString(nums));
        int[] res = sort(nums);
        System.out.println("排序结束----------------->" + Arrays.toString(res));
    }

    public static int[] sort(int[] arr) {
        for (int i = 1;i<arr.length;i++) {
            for (int j = i;j>0;j--) {
                if (arr[j-1] > arr[j]) {
                    int temp = arr[j];
                    arr[j] = arr[j-1];
                    arr[j-1] = temp;
                }
            }
        }
        return arr;
    }

}
